# Project: lwIP
# Makefile created by Dev-C++ 5.11

CPP      = g++.exe
CC       = gcc.exe
LD		 = ld.exe
WINDRES  = windres.exe
OBJDEST  = ./../../../views/build/net

COREFILES = $(OBJDEST)/init.o \
	$(OBJDEST)/def.o \
	$(OBJDEST)/dns.o \
	$(OBJDEST)/inet_chksum.o \
	$(OBJDEST)/ip.o \
	$(OBJDEST)/mem.o \
	$(OBJDEST)/memp.o \
	$(OBJDEST)/netif.o \
	$(OBJDEST)/pbuf.o \
	$(OBJDEST)/raw.o \
	$(OBJDEST)/stats.o \
	$(OBJDEST)/sys.o \
	$(OBJDEST)/tcp.o \
	$(OBJDEST)/tcp_in.o \
	$(OBJDEST)/tcp_out.o \
	$(OBJDEST)/timeouts.o \
	$(OBJDEST)/udp.o \
	$(OBJDEST)/sys_arch.o

CORE4FILES = $(OBJDEST)/autoip.o \
	$(OBJDEST)/dhcp.o \
	$(OBJDEST)/etharp.o \
	$(OBJDEST)/icmp.o \
	$(OBJDEST)/igmp.o \
	$(OBJDEST)/ip4_frag.o \
	$(OBJDEST)/ip4.o \
	$(OBJDEST)/ip4_addr.o

APIFILES = $(OBJDEST)/api_lib.o \
	$(OBJDEST)/api_msg.o \
	$(OBJDEST)/err.o \
	$(OBJDEST)/netbuf.o \
	$(OBJDEST)/netdb.o \
	$(OBJDEST)/netifapi.o \
	$(OBJDEST)/sockets.o \
	$(OBJDEST)/tcpip.o

NETIFFILES = $(OBJDEST)/ethernet.o
#	$(OBJDEST)/slipif.o

OBJ      = $(COREFILES) $(CORE4FILES) $(APIFILES) $(NETIFFILES)
LINKOBJ  = $(OBJ)

LIBS     = -static-libgcc -m32
INCS     = -I"./include" -I"./../../../views/include" -I"./../../../views/include/kernel" -I"./../../../views/include/std"
CXXINCS  = $(INCS)
BIN      = $(OBJDEST)/lwip.o
CXXFLAGS = $(CXXINCS) -m32 -O3 -pipe
CFLAGS   = $(INCS) -m32 -O3 -pipe
RM       = rm.exe -f

.PHONY: all all-before all-after clean clean-custom

all: all-before $(BIN) all-after

clean: clean-custom
	${RM} $(OBJ) $(BIN)

$(BIN): $(OBJ)
	$(LD) -r $(LINKOBJ) -o $(BIN)

#------ core -----------------------------------

$(OBJDEST)/init.o: ./core/init.c
	$(CC) -c ./core/init.c -o $(OBJDEST)/init.o $(CFLAGS)

$(OBJDEST)/def.o: ./core/def.c
	$(CC) -c ./core/def.c -o $(OBJDEST)/def.o $(CFLAGS)

$(OBJDEST)/dns.o: ./core/dns.c
	$(CC) -c ./core/dns.c -o $(OBJDEST)/dns.o $(CFLAGS)

$(OBJDEST)/inet_chksum.o: ./core/inet_chksum.c
	$(CC) -c ./core/inet_chksum.c -o $(OBJDEST)/inet_chksum.o $(CFLAGS)

$(OBJDEST)/ip.o: ./core/ip.c
	$(CC) -c ./core/ip.c -o $(OBJDEST)/ip.o $(CFLAGS)

$(OBJDEST)/mem.o: ./core/mem.c
	$(CC) -c ./core/mem.c -o $(OBJDEST)/mem.o $(CFLAGS)

$(OBJDEST)/memp.o: ./core/memp.c
	$(CC) -c ./core/memp.c -o $(OBJDEST)/memp.o $(CFLAGS)

$(OBJDEST)/netif.o: ./core/netif.c
	$(CC) -c ./core/netif.c -o $(OBJDEST)/netif.o $(CFLAGS)

$(OBJDEST)/pbuf.o: ./core/pbuf.c
	$(CC) -c ./core/pbuf.c -o $(OBJDEST)/pbuf.o $(CFLAGS)

$(OBJDEST)/raw.o: ./core/raw.c
	$(CC) -c ./core/raw.c -o $(OBJDEST)/raw.o $(CFLAGS)

$(OBJDEST)/stats.o: ./core/stats.c
	$(CC) -c ./core/stats.c -o $(OBJDEST)/stats.o $(CFLAGS)

$(OBJDEST)/sys.o: ./core/sys.c
	$(CC) -c ./core/sys.c -o $(OBJDEST)/sys.o $(CFLAGS)

$(OBJDEST)/tcp.o: ./core/tcp.c
	$(CC) -c ./core/tcp.c -o $(OBJDEST)/tcp.o $(CFLAGS)

$(OBJDEST)/tcp_in.o: ./core/tcp_in.c
	$(CC) -c ./core/tcp_in.c -o $(OBJDEST)/tcp_in.o $(CFLAGS)

$(OBJDEST)/tcp_out.o: ./core/tcp_out.c
	$(CC) -c ./core/tcp_out.c -o $(OBJDEST)/tcp_out.o $(CFLAGS)

$(OBJDEST)/timeouts.o: ./core/timeouts.c
	$(CC) -c ./core/timeouts.c -o $(OBJDEST)/timeouts.o $(CFLAGS)

$(OBJDEST)/udp.o: ./core/udp.c
	$(CC) -c ./core/udp.c -o $(OBJDEST)/udp.o $(CFLAGS)

$(OBJDEST)/sys_arch.o: ./core/sys_arch.c
	$(CC) -c ./core/sys_arch.c -o $(OBJDEST)/sys_arch.o $(CFLAGS)

# --------- ipv4 -----------------------

$(OBJDEST)/autoip.o: ./core/ipv4/autoip.c
	$(CC) -c ./core/ipv4/autoip.c -o $(OBJDEST)/autoip.o $(CFLAGS)

$(OBJDEST)/dhcp.o: ./core/ipv4/dhcp.c
	$(CC) -c ./core/ipv4/dhcp.c -o $(OBJDEST)/dhcp.o $(CFLAGS)

$(OBJDEST)/etharp.o: ./core/ipv4/etharp.c
	$(CC) -c ./core/ipv4/etharp.c -o $(OBJDEST)/etharp.o $(CFLAGS)

$(OBJDEST)/icmp.o: ./core/ipv4/icmp.c
	$(CC) -c ./core/ipv4/icmp.c -o $(OBJDEST)/icmp.o $(CFLAGS)

$(OBJDEST)/igmp.o: ./core/ipv4/igmp.c
	$(CC) -c ./core/ipv4/igmp.c -o $(OBJDEST)/igmp.o $(CFLAGS)

$(OBJDEST)/ip4_frag.o: ./core/ipv4/ip4_frag.c
	$(CC) -c ./core/ipv4/ip4_frag.c -o $(OBJDEST)/ip4_frag.o $(CFLAGS)

$(OBJDEST)/ip4.o: ./core/ipv4/ip4.c
	$(CC) -c ./core/ipv4/ip4.c -o $(OBJDEST)/ip4.o $(CFLAGS)

$(OBJDEST)/ip4_addr.o: ./core/ipv4/ip4_addr.c
	$(CC) -c ./core/ipv4/ip4_addr.c -o $(OBJDEST)/ip4_addr.o $(CFLAGS)


# ------- sequential and socket APIs -------------

$(OBJDEST)/api_lib.o: ./api/api_lib.c
	$(CC) -c ./api/api_lib.c -o $(OBJDEST)/api_lib.o $(CFLAGS)

$(OBJDEST)/api_msg.o: ./api/api_msg.c
	$(CC) -c ./api/api_msg.c -o $(OBJDEST)/api_msg.o $(CFLAGS)

$(OBJDEST)/err.o: ./api/err.c
	$(CC) -c ./api/err.c -o $(OBJDEST)/err.o $(CFLAGS)

$(OBJDEST)/netbuf.o: ./api/netbuf.c
	$(CC) -c ./api/netbuf.c -o $(OBJDEST)/netbuf.o $(CFLAGS)

$(OBJDEST)/netdb.o: ./api/netdb.c
	$(CC) -c ./api/netdb.c -o $(OBJDEST)/netdb.o $(CFLAGS)

$(OBJDEST)/netifapi.o: ./api/netifapi.c
	$(CC) -c ./api/netifapi.c -o $(OBJDEST)/netifapi.o $(CFLAGS)

$(OBJDEST)/sockets.o: ./api/sockets.c
	$(CC) -c ./api/sockets.c -o $(OBJDEST)/sockets.o $(CFLAGS)

$(OBJDEST)/tcpip.o: ./api/tcpip.c
	$(CC) -c ./api/tcpip.c -o $(OBJDEST)/tcpip.o $(CFLAGS)

# -------- generic network interface functions -------

$(OBJDEST)/ethernet.o: ./netif/ethernet.c
	$(CC) -c ./netif/ethernet.c -o $(OBJDEST)/ethernet.o $(CFLAGS)

$(OBJDEST)/slipif.o: ./netif/slipif.c
	$(CC) -c ./netif/slipif.c -o $(OBJDEST)/slipif.o $(CFLAGS)
